package org.onejava.core.manage;

import java.util.HashMap;

import org.onejava.core.bean.Allconfig;
import org.onejava.core.bean.PluginEntity;
import org.onejava.core.bean.imp.IocPlugin;
import org.onejava.core.tools.ObjectTools;

public class PluginManage {
	private static PluginManage manange;
	private HashMap<String,PluginEntity> entityMap;
	private PluginManage(){
		
	}
	public void intiMap(String packagePath) throws Exception{
		if(null!=entityMap){
			return;
		}
		entityMap = new  HashMap<String,PluginEntity>();
		//加载Spring插件
		if(!"".equals(Allconfig.springXml)){
			IocPlugin ip = (IocPlugin) ObjectTools.getTheObject(Allconfig.iocPluginPath);
			ip.inti(Allconfig.springXml);
			PluginEntity pe = new PluginEntity();
			pe.setPluginName("springXml");
			pe.setObj(ip);
			entityMap.put("Ioc", pe);
		}
	}
	public static PluginManage getManage(){
		if(null==manange){
			manange = new  PluginManage();
		}
		return manange;		
	}
	public IocPlugin getIocPlugin(){
		return (IocPlugin) entityMap.get("Ioc").getObj();
	}
}
